package com.itheima.Test07;

import java.util.Calendar;

public class Demo07 {
    public static void main(String[] args) {
        /*
        请编写程序，使用Calendar类获取日历对象，
        并分别获取年、月、日、小时、分、秒，并将它们打印到控制台。
         */
        Calendar instance = Calendar.getInstance();
        System.out.println( instance.get(Calendar.YEAR));
        int month = instance.get(Calendar.MONTH);
        System.out.println( month+1);
        System.out.println( instance.get(Calendar.DAY_OF_MONTH));
        System.out.println( instance.get(Calendar.HOUR));
        System.out.println( instance.get(Calendar.MINUTE));
        System.out.println( instance.get(Calendar.SECOND));
    }

    private static void method() {
        Calendar a = Calendar.getInstance();
        System.out.println(a);
        int year = a.get(Calendar.YEAR);
        System.out.println(year+"年");
        int month = a.get(Calendar.MONTH);
        System.out.println((month+1)+"月");
        int day = a.get(Calendar.DAY_OF_MONTH);
        System.out.println(day+"日");
        int hour = a.get(Calendar.HOUR);
        System.out.println(hour+"时");
        int minute = a.get(Calendar.MINUTE);
        System.out.println(minute+"分");
        int second = a.get(Calendar.SECOND);
        System.out.println(second+"秒");
    }
}
